<?php


namespace app\api\controller\shouye;

use app\common\controller\Api;
use think\Db;


class Pages extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 初始化
     */
    public function init()
    {
        $banner = model('app\admin\model\classroom\Banner')->where('type', 0)->where('status', 'normal')->order("weigh", "desc")->select();
        foreach ($banner as $k => $v) {
            $banner[$k]['image'] = cdnurl($v['image'], true);
        }

        // $notice = Db::name('classroom_article')->where('status', '=', '1')->order('weigh', 'desc')->limit(3)->select();
        // $navi = Db::name('classroom_type')->where('status', '=', '1')->where("pid", "=", "0")->limit(8)->order('weigh', 'desc')->select();
        // foreach ($navi as $k => $v) {
        //     $navi[$k]['image'] = cdnurl($v['image'], true);
        // }
        // $course_rows =  Db::name('classroom_course')->where('status', '=', '1')->order('weigh', 'desc')->limit(10)->select();
        // foreach ($course_rows as $k => $v) {
        //     $course_rows[$k]['image'] = cdnurl($v['image'], true);
        //     $course_rows[$k]['study_num'] = Db::name("classroom_course_record")->where('course_id', $v['id'])->group('user_id')->count();
        // }
        // $teachers = Db::name('classroom_author')->where('status', '=', '1')->order('weigh', 'desc')->limit(6)->select();
        // foreach ($teachers as $k => $v) {
        //     $teachers[$k]['image'] = cdnurl($v['image'], true);
        // }
        // $addonConfig = get_addon_config('classroom');
        // unset($addonConfig['qy_wechat_agentid'], $addonConfig['qy_wechat_appid'], $addonConfig['qy_wechat_redirect_uri'], $addonConfig['qy_wechat_secret'], $addonConfig['api_secretKey']);
        // $test_rows = Db::name('classroom_test')->where('status', '=', '1')->order('weigh', 'desc')->limit(10)->select();

        $this->success('ok', [
            'banner' => $banner,
            // 'notice' => array_column(collection($notice)->toArray(), 'title'),
            // 'notice_rows' => $notice,
            // 'navi' => $navi,
            // 'course_rows' => $course_rows,
            // 'teachers' => $teachers,
            // 'addonConfig' => $addonConfig,
            // 'test_rows' => $test_rows
        ]);
    }
}
